﻿using Microsoft.EntityFrameworkCore;
using System;

namespace Helpers.Dal
{
    /// <summary>
    /// mysql ef core
    /// "server=192.168.1.125;Database=ADC;user id=root;password=smartdo2017;charset=utf8;SslMode=None"
    /// dal.Database.ExecuteSqlCommand("insert into test (`Id`) values ({0})",3);
    /// </summary>
    public partial class MySqlDal: DbContext
    {
        private string connectionString;
        public MySqlDal(string connectionString)
        {
            this.connectionString = connectionString;
        }
        public MySqlDal(DbContextOptions options) :base(options)
        {
        }
        /// <summary>
        /// 依赖注入需要
        /// </summary>
        /// <param name="options"></param>
        public MySqlDal(DbContextOptions<MySqlDal> options) : base(options) { }
        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            //optionsBuilder.UseMySQL(connectionString);
            optionsBuilder.UseMySql(connectionString);
            base.OnConfiguring(optionsBuilder);
        }
    }
}
